package Test;

import static org.junit.Assert.*;

import org.junit.Test;

import Model.User;

/**
 * A test class for User.
 * 
 * @author Irving Estrera
 * */
public class TestUser
{
  public static final User TEST_USER = new User("Eric Cartman", "testAuthor",
      "testAuthor@yahoo.com");

  @Test
  public void testEquals()
  {
    // creates a new User object with the exact same fields as TEST_USER
    final User same_user = new User("Eric Cartman", "testAuthor",
        "testAuthor@yahoo.com");
    assertEquals(same_user, TEST_USER);
    assertTrue(TEST_USER.equals(same_user));

    // creates a new User with the same name but different username and email
    final User different_user = new User("Eric Cartman", "testAuthor2",
        "testAuthor2@yahoo.com");
    assertFalse(TEST_USER.equals(different_user));

    // User equality returns true
    // if both users have the same username OR email
    final User different_user_with_same_email = new User("User1",
        "User1_username", "testAuthor@yahoo.com");

    assertEquals(different_user_with_same_email, TEST_USER);
  }
}
